package cn.hpu.mobile_bank.exception;

import lombok.Data;

/**
 * 自定义业务异常
 */

@Data
public class BusinessException extends RuntimeException{
    protected Integer errorCode;
    protected String errorMsg;
    public BusinessException(String errorMsg) {
        super(errorMsg);
        this.errorCode = CommonErrorEnum.BUSINESS_ERROR.getErrorCode();
        this.errorMsg = errorMsg;
    }
    public BusinessException(Integer errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BusinessException(CommonErrorEnum commonErrorEnum) {
        super(commonErrorEnum.getErrorMsg());
        this.errorCode = commonErrorEnum.getErrorCode();
        this.errorMsg = commonErrorEnum.getErrorMsg();
    }
}
